#include "plugincore.h"
#include "client/client.h"

PluginCore::PluginCore(QObject *parent) : QObject(parent){
}

void PluginCore::loadPlugin(QObject *object, QString file){
    if (object->inherits("Plugin")){
        Plugin *plugin = qobject_cast<Plugin *>( object );
        if(plugin){
            plugins.insert("GENERIC", plugin);
        }
    }
}

void PluginCore::loadPlugins(QDir path){
    qDebug() << "Loading plugins from [" + path.absolutePath() + "]";

    foreach( QString fileName, path.entryList( QDir::Files ) ) {
        QPluginLoader loader( path.absoluteFilePath( fileName ) );
        QObject *plugin = loader.instance();
        if( plugin ){
            loadPlugin( plugin, fileName);
        }
    }

    int count = plugins.count();
}
